index = [6, 8, 9, 12, 15, 16, 18, 20];
i = 6;
for i = 1:length(index)
figure('NumberTitle', 'off', 'Name', ['final out, N = ',num2str(index(i))]);
PopSize = 150;
Gen = 200;
P = init(PopSize, index(i));
for i = 1:Gen/5
    P = Select(P, 0.8, PopSize);
    P = Crossover(P);
    P = Mutation(P);
    i
    if rem(i, 10) == 0
        P = SortP(P);
        Show(P([1:0.05*PopSize],:))
    end
end

for i = 1:Gen
    
    P = Select(P, 0.5, PopSize);
    P = Mutation(P);
    i
    if rem(i, 10) == 0
        P = SortP(P);
        Show(P([1:0.05*PopSize],:))
    end
end

for i = 1:Gen/5
    P = Select(P, 0.1, PopSize);
    P = Mutation(P);
    i
    if rem(i, 10) == 0
        P = SortP(P);
        Show(P([1:0.05*PopSize],:))
    end
end
P = SortP(P);
P = P([1:0.1*PopSize],:);
%Process(P)
end